/**
  ******************************************************************************
  * @file   :   main.c
  * @version:
  * @author :
  * @brief  :
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright(c) . BLUEX Microelectronics.
  * All rights reserved.</center></h2>
  *
  *
  ******************************************************************************
  */

/* includes ------------------------------------------------------------------*/

#include "bx_kernel.h"
#include "user_app.h"

#include "bx_service_gpio.h"
#include "bx_shell.h"
/* private define ------------------------------------------------------------*/

/* private typedef -----------------------------------------------------------*/

/* private variables ---------------------------------------------------------*/

/* exported variables --------------------------------------------------------*/


/*============================= private function =============================*/

/*========================= end of private function ==========================*/


/*============================= exported function ============================*/
/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
void user_init( void )
{
    bxs_gpio_register();
}

/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
void user_app( void )
{
    s32 id = bxs_gpio_a_id();
    bx_call( bxs_gpio_a_id(), BXM_OPEN, 0, 0 );
    bx_set(id,BXP_MODE,2,BX_GPIO_MODE_OUTPUT);
    
    bx_set(id,BXP_GPIO_PULL,15,BX_GPIO_PULLUP);
    bx_set(id,BXP_MODE,15,BX_GPIO_MODE_EIT_RISING);
    bx_subscibe( id, BXM_GPIO_EXT_INTR, 0, 0 );
}
/** ---------------------------------------------------------------------------
 * @brief   :
 * @note    :
 * @param   :
 * @retval  :
-----------------------------------------------------------------------------*/
bx_err_t user_msg_handle_func( s32 id, u32 msg, u32 param0, u32 param1 )
{
    if( bx_msg_source() == bxs_gpio_a_id() ) {
        switch( msg ) {
            case BXM_GPIO_EXT_INTR:
                bxsh_logln( "BXM_GPIO_EXT_INTR" );
                bx_post( bxs_gpio_a_id(),BXM_TOGGLE,2,0 );
                break;

            default:
                break;
        }
    }
    return BX_OK;
}
/*========================= end of exported function =========================*/


/*============================= import function ==============================*/

/*=========================== end of import function =========================*/


/*============================ interrupt function ============================*/

/*========================= end of interrupt function ========================*/


/******************** (C) COPYRIGHT BLUEX **********************END OF FILE****/



